package com.flower.sequence.service.string;

import com.flower.sequence.service.SegmentGenerator;
import com.flower.sequence.service.StringSequenceGenerator;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.w3c.dom.Element;

import java.util.List;

/**
 * @author shanks on 2019-10-12
 */

public class CompositeStringSequenceGenerator implements StringSequenceGenerator {

    /**
     * 序列号片段生成器列表
     */
    private List<SegmentGenerator> segmentGenerators;

    public List<SegmentGenerator> getSegmentGenerators() {
        return segmentGenerators;
    }

    public void setSegmentGenerators(List<SegmentGenerator> segmentGenerators) {
        this.segmentGenerators = segmentGenerators;
    }

    @Override
    public String getStringSequence() {
        StringBuilder sequenceBuilder = new StringBuilder();
        for (SegmentGenerator segmentGenerator : segmentGenerators) {
            String stringSegment = segmentGenerator.getStringSegment();
            sequenceBuilder.append(stringSegment);
        }
        return sequenceBuilder.toString();
    }


}
